package com.ziyun.erp.web.modules.report.controller;

import com.ziyun.erp.modules.report.entity.ReportStoreProductPriceEntity;
import com.ziyun.erp.modules.report.service.ReportStoreProductPriceService;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 门店商品价格报表
 *
 * @author jiangli
 * @email 
 * @date 2019-02-22 11:40:50
 */
@RestController
@RequestMapping("mercharReport/storeproductprice")
public class ReportStoreProductPriceController {
    @Autowired
    private ReportStoreProductPriceService storeProductPriceService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("mercharReport:storeproductprice:list")
    public R list(@RequestParam Map<String, Object> params){
        return storeProductPriceService.list(params);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{stepId}")
    @RequiresPermissions("mercharReport:storeproductprice:info")
    public R info(@PathVariable("stepId") Integer stepId){
        ReportStoreProductPriceEntity storeProductPrice = storeProductPriceService.selectById(stepId);

        return R.ok().put("storeProductPrice", storeProductPrice);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("mercharReport:storeproductprice:save")
    public R save(@RequestBody ReportStoreProductPriceEntity storeProductPrice){
        storeProductPriceService.insert(storeProductPrice);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("mercharReport:storeproductprice:update")
    public R update(@RequestBody ReportStoreProductPriceEntity storeProductPrice){
        ValidatorUtils.validateEntity(storeProductPrice);
        storeProductPriceService.updateById(storeProductPrice);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("mercharReport:storeproductprice:delete")
    public R delete(@RequestBody Integer[] stepIds){
        storeProductPriceService.deleteBatchIds(Arrays.asList(stepIds));

        return R.ok();
    }

}
